<template>
  <div id="targetlist" > 

 
          <el-table :data="datalist" style="width: 100%" :row-class-name="tableRowClassName" 
           :border="true" :height="dtheight" :header-cell-style="{background:'#4F81BC',color:'white'}"
          >

                 <!-- <el-table-column label="添加时间"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.name }}</span>
                    </template>
                </el-table-column> -->
                 <el-table-column label="账号"  align='center' >                   
                    <template slot-scope="scope">  
                        <span style="display: flex;align-items: center;justify-content: center;">
                                 {{ scope.row.telphone }}
                                <img src="@/assets/images/a9.png" style="width:18px;height:20px;margin-left:5px;" @click="goinforpersonal(scope.row,scope.row.telphone)"/>
                        </span>                 
                    </template>
                </el-table-column>
                 <el-table-column label="用户名"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.nickname }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="新增要求"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.news_num }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="达到权限"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.manor_title }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="开始时间"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ getNowDateSjc(scope.row.starttime *1000) }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="结束时间"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ getNowDateSjc(scope.row.endtime *1000) }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="是否达成"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span v-if="scope.row.is_achieve ==0">未达成</span>
                        <span v-if="scope.row.is_achieve ==1">已达成</span>
                    </template>
                </el-table-column>
                 <el-table-column label="达成数量"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.achieve_num }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="操作" align='center' width="300px"  fixed="right">
                    <template slot-scope="scope">
                        <el-button size="mini"  type="primary"  plain class="button_class1" @click="mtk1_but(scope.row)">目标管理</el-button> 
                        <el-button size="mini"  type="primary"  plain class="button_class2" @click="go_but(scope.row)">达成奖励</el-button>
                    </template>
                </el-table-column>

            </el-table>  


       <el-dialog title="目标管理" :visible.sync="mtk1"  width="500px" >
          <el-form ref="form"   label-width="80px" style="width:100%;">
               
                 <el-form-item label="新增数量">
                    <el-input v-model="mtk1_form.number" placeholder="必填"></el-input>
                </el-form-item>
                <el-form-item  label="选择权限" >
                  <el-select  v-model="mtk1_form.select_num_zy" placeholder="请选择蜂巢" style="width:100%;">
                      <el-option  v-for="(item,index) in select_data_zy" :key="index" :label="item.title" :value="item.maid"></el-option>
                  </el-select>
              </el-form-item>
                <el-form-item  label="完成区间" >
                      <div style="display: flex;">
                            <el-date-picker  type="date"   placeholder="开始日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="mtk1_form.start" style="felx:1;"></el-date-picker>
                            <div style="width:20px;height:40px;line-height:40px;text-align: center;"> - </div>
                            <el-date-picker  type="date"   placeholder="结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="mtk1_form.end" style="felx:1;"></el-date-picker>
                      </div>
               </el-form-item>

              
         </el-form>
          <div style="text-align: center;width:70%;margin:auto;">
                  <el-button type="primary" class="custom_color_button" style="width:80%;" @click="mtk1_but_qr()">确认</el-button>
          </div>

   </el-dialog> 
 


   </div>
</template>

<script>
export default {
   name: 'targetlistlist',
   props:{
      datalist:{  
        //type:Array,
       default:()=>[]
     },
  },
  data () {
    return {
        dtheight:'500',  //窗口高度
        mtk1:false,
        mtk1_form:{
            number:'',
            start:'',
            end:'',
            select_num_zy:'',
            
        },
        select_data_zy:[],
        target_id:''
        
    }
  },
   components:{

  },
  created(){
     this.dtheight = window.innerHeight - 405
      this.list_zy()
  },
  mounted (){
   
  },
  methods: {
     list_zy(){
        this.post("/manor/manorOption", {
        }).then(res => { 
            this.select_data_zy = res.result     
            //console.log(this.select_data_zy)                  
        })
      },
      mtk1_but(row){
           this.target_id = row.target_id
           this.mtk1_form.number =  row.news_num
           this.mtk1_form.select_num_zy =  row.achieve_maid
           this.mtk1_form.start =  this.getNowDateSjc(row.starttime *1000) 
           this.mtk1_form.end =  this.getNowDateSjc(row.endtime *1000) 
           this.mtk1 = true
      },
      mtk1_but_qr(){     
         this.post("/target/updateTarget", {
                target_id:this.target_id,
               news_num:this.mtk1_form.number,
               maid:this.mtk1_form.select_num_zy,
               starttime:this.mtk1_form.start,
               endtime:this.mtk1_form.end,
	         }).then(res => {

                 if(res.error_code == 0){
                    this.$emit('up_list_fun')
                    this.target_id = ''
                    this.mtk1 = false
                     this.open1(res.result,'success')  //提示框
                }else {
                    this.open1(res.message,'warning')
                }


          })

      },
      go_but(row){
       this.$router.push({
          path: '/index/rewardtarget',
          query: {
            name:row.telphone,
            id:row.target_id
          }
        })
    },
    goinforpersonal(row,telphone){      
        this.$router.push({
          path: '/index/inforpersonal',
          query: {
            name:telphone,
          }
        })
    }


  }
}
</script>


<style scoped>

</style>